package com.github.fastjson;

import com.alibaba.fastjson2.JSON;
import com.alibaba.fastjson2.JSONObject;
import com.alibaba.fastjson2.JSONPath;
import org.junit.jupiter.api.Test;

/**
 * @author zhangcheng
 * @date 2022/10/25 10:42
 * @description
 */
public class JsonTest {

    public static void main(String[] args) {
        String jsonStr = "{\n" +
                "    \"store\": {\n" +
                "        \"bicycle\": {\n" +
                "            \"color\": \"red\",\n" +
                "            \"price\": 19.95\n" +
                "        },\n" +
                "        \"book\": [\n" +
                "            {\n" +
                "                \"author\": \"刘慈欣\",\n" +
                "                \"price\": 8.95,\n" +
                "                \"category\": \"科幻\",\n" +
                "                \"title\": \"三体\"\n" +
                "            },\n" +
                "            {\n" +
                "                \"author\": \"itguang\",\n" +
                "                \"price\": 12.99,\n" +
                "                \"category\": \"编程语言\",\n" +
                "                \"title\": \"go语言实战\"\n" +
                "            }\n" +
                "        ]\n" +
                "    }\n" +
                "}";
        JSONObject jsonObject = JSON.parseObject(jsonStr);
        String store = jsonObject.getString("store");
        System.out.println(store);
    }


    @Test
    public void test() {
        MqttMessage mqttMessage = new MqttMessage();
        mqttMessage.setIsSuccess(true);

        String s = JSON.toJSONString(mqttMessage);
        System.out.println(s);

    }

    @Test
    public void test1() {
        System.out.println("230403_232922_55HDE5_BH2_1AE5330112N_PC3.csv".matches("^\\d{6}_\\d{6}_[\\w,\\d]{6}_[\\w,\\d]{3}_[\\w,\\d]{11}_[\\w,\\d]{3}.csv$"));
        System.out.println("230403_232922_55HDE5_BH2_1AE5330112N_PC3.csv".endsWith(".csv"));


    }
}
